{%extend name="Public:layout"/%}

{%block name="title"%}
<h2 class="mb20">
    表单记录
</h2>
{%/block%}

{%block name="contents"%}
<div class="heading clearfix">
    <div class="pull-left">
        <form class="form-inline" onsubmit="return false;" stverify="true" method="get" action="">
            <input class="input input-small" type="text" name="username" value="{%$username%}" placeholder="姓名" />
            <input type="submit" class="btn" value="搜索">
        </form>
    </div>
    <div class="pull-right">
    </div>
</div>
<table class="table table-listing table-hovered">
    <thead class="thead-gray">
    <tr>
        <th>姓名</th>
        <th>电话</th>
        <th>QQ</th>
        <th>邮箱</th>
        <th>收货地址</th>
        <th>IP地址</th>
        <th>提交时间</th>
    </tr>
    </thead>
    <tbody>
    {%notempty name="list"%}
    {%foreach name="list" item="vo" %}
    <tr>
        <td>{%$vo.username%}</td>
        <td>
            {%$vo.telephone%}
        </td>
        <td>
            {%$vo.qq%}
        </td>
        <td>
            {%$vo.email%}
        </td>
        <td>
            {%$vo.address%}
        </td>
        <td>
            {%$vo.ip|long2ip%}
        </td>
        <td>{%$vo.add_time|date='Y-m-d H:i:s',###%}
        </td>
    </tr>
    {%/foreach%}
    {%/notempty%}
    </tbody>
</table>
<h2 class="m20"></h2>
<div class="paging">{%$page%}</div>
{%/block%}

{%block name="js"%}
<script>
    $.extend(ST.ACTION, {
        'del': "{%:U('/admin/user/del')%}",//删除目录action地址
        'save': "{%:U('/admin/user/save')%}",//添加目录弹窗地址
        'edit_pwd': "{%:U('/admin/user/edituserpwd')%}"//编辑目录弹窗地址
    });
    $.extend(ST, {
        save: function (id) {
            ST.editBox(ST.ACTION.save + '/user_id/' + user_id, {
                title: '修改角色',
                height: 500
            });
        },
        edit_pwd: function (id) {
            ST.editBox(ST.ACTION.edit_pwd + '/id/' + id, {
                title: '修改登录密码',
                height: 500
            });
        },
        del: function (id) {
            ST.execAJAX({
                url: ST.ACTION.del,     //服务端请求地址
                params: {id: id},       //发送到服务端的参数（如：{myparam:1}）
                massage: '确定删除吗？',       //提示信息（仅hasconfirm为true时有用）
                hasconfirm: true,       //提交前是否显示确认框
                succFun: function (j) {  //成功后的回调方法：刷新页面
                    if (!j) return;
                    if (j.data && j.data.url) {
                        location.href = j.data.url;
                    } else {
                        ST.reload();
                    }
                }
            });
        },
        //批量删除
        delAll: function () {
            var ids = ST.getSelectedValue().join(',');
            if (!ids) {
                ST.tipMsg('请至少选择一项');
            } else {
                ST.del(ids);
            }
        },
        //获得选中值
        getSelectedValue: function () {
            var $options = $('.js-toggleall-target:checked'), arr = [];
            $options.each(function () {
                arr.push($(this).val());
            });
            return arr;
        }
    });
    ST.init();
</script>
{%/block%}